package com.jspmine.qa.dao;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import com.jspmine.qa.pojo.Problem;
import org.springframework.data.jpa.repository.Query;

/**
 * problem数据访问接口
 * @author Administrator
 *
 */
public interface ProblemDao extends JpaRepository<Problem,String>,JpaSpecificationExecutor<Problem>{


   @Query(value = "select * from tb_problem p left join tb_pl on p.id=tb_pl.problemid and tb_pl.labelid=?1 order by p.replytime desc",nativeQuery = true)
    Page<Problem> findnewList(String label, Pageable of);

    @Query(value = "select * from tb_problem p left join tb_pl on p.id=tb_pl.problemid and tb_pl.labelid=?1 order by p.reply desc",nativeQuery = true)
    Page<Problem> findHostList(String label, Pageable of);

    @Query(value = "select * from tb_problem p left join tb_pl on p.id=tb_pl.problemid and p.reply=0 and tb_pl.labelid=?1 ",nativeQuery = true)
    Page<Problem> findWaitList(String label, Pageable of);
}
